package xuegao.study.mall.admin.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xuegao.study.mall.admin.feign.UmsResourceCategoryClient;
import xuegao.study.mall.common.api.CommonResult;
import xuegao.study.mall.common.model.ums.UmsResourceCategory;

import java.util.List;

/**
 * 资源分类管理
 */
@RestController
@RequestMapping("/resourceCategory")
public class UmsResourceCategoryController {

    @Autowired
    private UmsResourceCategoryClient umsResourceCategoryClient;

    @ApiOperation("新增资源分类")
    @PostMapping("/add")
    public CommonResult<Integer> add(@RequestBody UmsResourceCategory category) {
        return umsResourceCategoryClient.add(category);
    }

    @ApiOperation("删除资源分类")
    @DeleteMapping("/delete/{id}")
    public CommonResult<Integer> delete(@PathVariable("id") Long id) {
        return umsResourceCategoryClient.delete(id);
    }

    @ApiOperation("更新资源分类")
    @PostMapping("/update/{id}")
    public CommonResult<Integer> update(@PathVariable("id") Long id, @RequestBody UmsResourceCategory category) {
        return umsResourceCategoryClient.update(id, category);
    }

    @ApiOperation("查询所有资源分类")
    @GetMapping("/listAll")
    public CommonResult<List<UmsResourceCategory>> listMenu(){
        return umsResourceCategoryClient.listMenu();
    }
}
